package com.demo.mqtt.zigbee.entity.po;

import javolution.io.Struct;
import lombok.extern.slf4j.Slf4j;

import java.nio.ByteOrder;


/**
 * @program: mqtt
 * @description: 特征值上传原始数据 头部分
 * @author: liuYunKai
 * @create: 2021-03-26 13:13
 */
@Slf4j
public class StHead extends Struct {
    //协议头
    public final Unsigned16 header = new Unsigned16();
    //协议版本号
    public final Unsigned8 version = new Unsigned8();
    //设备地址(BCD码格式)
    public final UTF8String addr = new UTF8String(6);
    //序列号
    public final Unsigned16 sn = new Unsigned16();
    //通讯命令
    public final Unsigned8 command = new Unsigned8();
    //数据长度(小端模式)
    public final Unsigned32 length = new Unsigned32();
    /**
     * 一定要加上这个，不然会出现对齐的问题
     * @return
     */
    @Override
    public boolean isPacked() {
        return true;
    }

    /**
     * 设置大小端
     * @return
     */
    @Override
    public ByteOrder byteOrder() {
        return ByteOrder.LITTLE_ENDIAN;
    }

}
